/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mamayukero.logic.pathfinding;

import java.awt.Point;
import java.util.ArrayList;
import mamayukero.debug.LogContainer;
import mamayukero.problem.environment.map.Map;
import mamayukero.problem.environment.map.Path;

public abstract class PathFindingBase {
    
    public Point start, end;
    public Map map;
    public Path path;
    public ArrayList<Point> pathlist = new ArrayList<Point>();
    public LogContainer log;
    
    public PathFindingBase(Map map) {
        this.map = map;
    }
    
        /**
	 * 
	 * @param x current position
	 * @param y current position
	 * @param map the map
	 * @return ArrayList<Point> points yg bisa dijalani dari posisi x dan y
	 *							maximum 4 arah
	 */
	public ArrayList<Point>  whereToGo(int x, int y, Map map) {
		ArrayList<Point> result = new ArrayList<Point>();
		int batasx = map.col;
		int batasy = map.row;

//            if (((x+1)<=batasx) && map.At(x+1,y)) result.add(new Point(x+1,y));
//            if ((x > 1) && map.At(x-1,y)) result.add(new Point(x-1,y));
//            if (((y+1)<=batasy) && map.At(x,y+1)) result.add(new Point(x,y+1));
//            if ((y > 1) && map.At(x,y-1)) result.add(new Point(x,y-1));
            
            if (((x+1)<batasx) && map.At(x+1,y)) result.add(new Point(x+1,y));
            if ((x > 0) && map.At(x-1,y)) result.add(new Point(x-1,y));
            if (((y+1)<batasy) && map.At(x,y+1)) result.add(new Point(x,y+1));
            if ((y > 0) && map.At(x,y-1)) result.add(new Point(x,y-1));
		return result;
	}
        
	public abstract Path solve(Point start, Point end);
}
